<?php
session_start();
include '../connect/db_connect.php';
include '../function/mysql.php';
?>
<script type="text/javascript">
	$("a.re_ans").bind('click',function(){
		var id=$(this).attr("id");
		var $this=$(this);
		
		$.ajax({
			type:'get',
			url:'modules/user/list_ans.php',
			data:'idquest='+id,
			success:function(result){
				//alert(result);
				$this.parents('div.wrap_ans').empty().hide().append(result).show();
				//$this.parents("div.wrap_ans").hide();
			}
		});
		
		return false;
	});
</script>
<div id="new_question">
    <h3>New Question</h3>
    <div class="wrap_ans">
    <?php 
		$sql='select * from u_profile_question as q
		where  q.idpr_question NOT IN(
								select uqa.idquestion
								from u_quest_answer as uqa
								where uqa.iduser="'.$_SESSION['userid'].'")
			and kind=0 order by q.idpr_question asc limit 0,1';
			$result=mysql_query($sql);
			echo mysql_error();
			$row=mysql_fetch_array($result);
			//print_r($row);
			
	?>
        <div class="answer"><?php echo $row['question'];?></div>
        <a href="#" id="<?php echo $row['idpr_question']?>" class="re_ans">Answer</a>
        <a href="#" id="<?php echo $row['idpr_question']?>" class="re_ans">Skip answer</a>
         <a href="#" id="<?php echo $row['idpr_question']?>" class="re_ans">Next</a>
    </div><!--end wrap_ans-->
</div>
<div id="q_profile">

<?php 
	$result=select_quest_user($_SESSION['userid'],0,0,0,1);
	echo mysql_error();
	$i=1;
	while($row=mysql_fetch_array($result)){
?>

<div class="question"><?php echo '<strong>'.$i++.'_  </strong>'.$row['ques'];?>
<div class="wrap_ans">
	<div class="answer"><?php echo $row['ans'];?></div>
	<div class="explain"><?php //echo $row['exp'];?>
	<a href="#" id="<?php echo $row['idq']?>" class="re_ans">re-answer</a></div>
</div><!--end wrap_ans-->
</div>
<br />
<br />
<?php		
	}
?>
</div>
